# 0vars - redefine cmakecache vars, needed by all other bundling scripts
# ! cmakecache vars not available to external scripts
#   so we configure it first to do substitutions
#   make sure to use @varname@

# kill boolean warnings
CMAKE_POLICY (SET CMP0012 NEW)

# cmake
SET (CPACK_PACKAGE_VERSION_MAJOR @CPACK_PACKAGE_VERSION_MAJOR@)
SET (CPACK_PACKAGE_VERSION_MINOR @CPACK_PACKAGE_VERSION_MINOR@)
SET (CMAKE_VERBOSE_MAKEFILE "@CMAKE_VERBOSE_MAKEFILE@")
SET (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
SET (CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@")

# Qt5 cmake does not create overall qt prefix var, only individual lib prefixes.
# For simplicity, assume core prefix same as all others
SET (QT_LIBRARY_DIR "@_qt5Core_install_prefix@/lib")

# OS X options
SET (CMAKE_OSX_ARCHITECTURES "@CMAKE_OSX_ARCHITECTURES@")

# QGIS
SET (QGIS_APP_NAME "@QGIS_APP_NAME@")
SET (QGIS_MACAPP_PREFIX "@QGIS_MACAPP_PREFIX@")
SET (QGIS_FW_SUBDIR "@QGIS_FW_SUBDIR@")
SET (QGIS_FW_SUBDIR_REV "@QGIS_FW_SUBDIR_REV@")
SET (QGIS_BIN_SUBDIR "@QGIS_BIN_SUBDIR@")
SET (QGIS_BIN_SUBDIR_REV "@QGIS_BIN_SUBDIR_REV@")
SET (QGIS_CGIBIN_SUBDIR "@QGIS_CGIBIN_SUBDIR@")
SET (QGIS_CGIBIN_SUBDIR_REV "@QGIS_CGIBIN_SUBDIR_REV@")
SET (QGIS_LIB_SUBDIR "@QGIS_LIB_SUBDIR@")
SET (QGIS_LIB_SUBDIR_REV "@QGIS_LIB_SUBDIR_REV@")
SET (QGIS_LIBEXEC_SUBDIR "@QGIS_LIBEXEC_SUBDIR@")
SET (QGIS_LIBEXEC_SUBDIR_REV "@QGIS_LIBEXEC_SUBDIR_REV@")
SET (QGIS_PLUGIN_SUBDIR "@QGIS_PLUGIN_SUBDIR@")
SET (QGIS_PLUGIN_SUBDIR_REV "@QGIS_PLUGIN_SUBDIR_REV@")
SET (QGIS_DATA_SUBDIR "@QGIS_DATA_SUBDIR@")
SET (QGIS_DATA_SUBDIR_REV "@QGIS_DATA_SUBDIR_REV@")
SET (QGIS_SERVER_MODULE_SUBDIR "@QGIS_SERVER_MODULE_SUBDIR@")

# optional components
SET (WITH_GRASS "@WITH_GRASS@")
SET (WITH_SERVER "@WITH_SERVER@")
SET (WITH_POSTGRESQL "@WITH_POSTGRESQL@")
SET (WITH_QSPATIALITE "@WITH_QSPATIALITE@")

# tests
SET (ENABLE_TESTS "@ENABLE_TESTS@")

# Python module search paths
# Allows overriding build variables with PYTHONPATH
# Handles case where resolved symlinked modules may not be where other resolved modules exist, e.g.
#   a site-packages directory where all packages/modules are symlinked in (like Homebrew),
#   and their respective install prefixes are completely different
# This also handles migration to next-gen sip/PyQt setup where sipconfig and pyqtconfig don't exist
#   and the sys.paths used to import the modules dictates how the modules are found
#   see: https://github.com/qgis/QGIS/pull/1508
SET (PYTHON_MODULE_PATHS)
STRING(REPLACE ":" ";" _pythonpath "$ENV{PYTHONPATH}")
LIST(APPEND PYTHON_MODULE_PATHS ${_pythonpath})
IF (EXISTS "@PYQT5_MOD_DIR@")
  LIST(APPEND PYTHON_MODULE_PATHS "@PYQT5_MOD_DIR@")
ENDIF ()
IF (EXISTS "@SIP_MODULE_DIR@")
  LIST(APPEND PYTHON_MODULE_PATHS "@SIP_MODULE_DIR@")
ENDIF ()
IF (EXISTS "@PYTHON_SITE_PACKAGES_SYS@")
  LIST(APPEND PYTHON_MODULE_PATHS "@PYTHON_SITE_PACKAGES_SYS@")
ENDIF ()
